package com.corpdata.system.org.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import com.corpdata.common.result.Result;
import com.corpdata.common.result.util.ResultUtil;
import com.corpdata.common.utils.CorpdataUtil;
import com.corpdata.core.base.AbstractBaseService;
import com.corpdata.system.org.dao.OrgRangeMapMapper;
import com.corpdata.system.org.dao.OrgRangeMapper;
import com.corpdata.system.org.entity.OrgRange;
import com.corpdata.system.org.entity.OrgRangeMap;
import com.corpdata.system.org.service.OrgRangeService;

/**
 * 
 * 
 * @author wu
 * @email 64088839@qq.com
 * @date 2018-08-22 15:38:37
 */
@Service
@Transactional
public class OrgRangeServiceImpl extends AbstractBaseService<OrgRange> implements OrgRangeService {
	@Autowired
	private OrgRangeMapper rangeMapper;
	@Autowired
	private OrgRangeMapMapper rangeMapMapper;
	
	@Override
	public List<OrgRange> findAll(Map<String, Object> params) {
		return rangeMapper.selectAll(params);
	}
	/**
	 * 保存范围权限
	 */
	
	@Override
	public Result saveRangeMap(OrgRangeMap record) {
		int i = -1;
		rangeMapMapper.delete(record.getFkRole(),record.getFkPermission());
		record.setId(CorpdataUtil.getUUID());
		i = rangeMapMapper.insert(record);
		if(i>0){
        	return ResultUtil.success();
    	}else{
    		return ResultUtil.fail();
    	}
	}
	
}
